﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text.RegularExpressions;

/// <summary>
///Check 的摘要说明
/// </summary>
public class AsCheck
{
	public AsCheck()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
	}
    /// <summary>
    ///检测邮箱格式是否为x@x.com或x@x.com.cn
    /// </summary>
    /// <param name="strIn"></param>
    /// <returns></returns>
    public bool IsValidEmail(string strIn)
    {
        strIn = strIn.Trim();
        return System.Text.RegularExpressions.Regex.IsMatch(strIn, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");
    }
    /// <summary>
    /// 检测用户名是否为数字、字母或下划线
    /// </summary>
    /// <param name="strIn"></param>
    /// <returns></returns>
    public bool IsValidUserName(string strIn)
    {
        strIn = strIn.Trim();
        return System.Text.RegularExpressions.Regex.IsMatch(strIn, @"^\w+$");
    }
    /// <summary>
    /// 检测是否全为中文
    /// </summary>
    /// <param name="strIn"></param>
    /// <returns></returns>
    public bool IsAllChinese(string strIn)
    {
        strIn = strIn.Trim();
        return System.Text.RegularExpressions.Regex.IsMatch(strIn, @"^[\u4e00-\u9fa5]{0,}$");
    }
    /// <summary>
    /// 检测字符串只否为字母和数字的组合
    /// </summary>
    /// <param name="strIn"></param>
    /// <returns></returns>
    public bool IsNumberAndLetter(string strIn)
    {
        strIn = strIn.Trim();
        return System.Text.RegularExpressions.Regex.IsMatch(strIn, @"^([A-Za-z0-9]+)$");
    }
    /// <summary>
    /// 检测用户名是否为中文、数字、字母、以及下划线
    /// </summary>
    /// <param name="strIn"></param>
    /// <returns></returns>
    public bool IsChineseAndNumb(string strIn)
    {
        strIn = strIn.Trim();
        return System.Text.RegularExpressions.Regex.IsMatch(strIn, @"[a-zA-Z0-9_\u4e00-\u9fa5]*");
    }
    /// <summary>
    /// 
    /// </summary>
    /// <param name="strInA">用于比较的字符串A</param>
    /// <param name="strInB">用于比较的字符串B</param>
    /// <returns></returns>
    public bool IsEQual(string strInA, string strInB)
    {
        strInA = strInA.Trim();
        strInB = strInB.Trim();
        if (strInA == strInB) return true;
        else
            return false;
    }
  /// <summary>
  /// 字符串是否小于限定的长度MinLength
  /// </summary>
  /// <param name="strIn"></param>
  /// <param name="MinLength">限定的最小长度</param>
  /// <returns></returns>
    public bool IsShortLen(string strIn,int MinLength)
    {
        strIn = strIn.Trim();
        if(strIn.Length<MinLength)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    public bool IsBetweenLen(string strIn,int MinLen,int MaxLen)
    {
        strIn = strIn.Trim();
        if (strIn.Length<=MaxLen||strIn.Length>=MinLen)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    /// <summary>
    /// 是否全为数字
    /// </summary>
    /// <param name="strIn"></param>
    /// <returns></returns>
    public bool IsAllNumber(string strIn)
    {
        strIn = strIn.Trim();
        return System.Text.RegularExpressions.Regex.IsMatch(strIn, @"^\d+$");
    }
}
